package com.cskaoyan.mall.product.controller;

import com.cskaoyan.mall.common.result.Result;
import com.cskaoyan.mall.product.dto.FirstLevelCategoryDTO;
import com.cskaoyan.mall.product.dto.SecondLevelCategoryDTO;
import com.cskaoyan.mall.product.dto.ThirdLevelCategoryDTO;
import com.cskaoyan.mall.product.model.FirstLevelCategory;
import com.cskaoyan.mall.product.service.impl.CategoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping
public class AdminProductCategoryController {

    @Autowired
    private CategoryServiceImpl categoryService;

    @GetMapping("/admin/product/getCategory1")
    public Result<List<FirstLevelCategoryDTO>>getCategory1(){
        List<FirstLevelCategoryDTO> firstLevelCategoryList=categoryService.getFirstLevelCategory();
        return Result.ok(firstLevelCategoryList);
    }

    @GetMapping("/admin/product/getCategory2/{firstLevelCategoryId}")
    public Result<List<SecondLevelCategoryDTO>> getCategory2(@PathVariable Long firstLevelCategoryId){
        List<SecondLevelCategoryDTO> secondLevelCategoryDTOList=categoryService.getSecondLevelCategory(firstLevelCategoryId);
        return Result.ok(secondLevelCategoryDTOList);
    }

    @GetMapping("/admin/product/getCategory3/{secondLevelCategoryId}")
    public Result<List<ThirdLevelCategoryDTO>> getCategory3(@PathVariable Long secondLevelCategoryId){
        List<ThirdLevelCategoryDTO> thirdLevelCategoryDTOList=categoryService.getThirdLevelCategory(secondLevelCategoryId);
        return Result.ok(thirdLevelCategoryDTOList);
    }
}
